package week04;
import java.util.*;

class PersonOverride{
	private String name;
	private int age;
	private boolean gender;
	
	public PersonOverride() {
		this("default",1,true);
	}
	
	public PersonOverride(String name,int age,boolean gender) {
		this.name 

=name;
		this.age=age;
		this.gender=gender;
	}

	@Override
	public String toString() {
		return name + "-" + age + "-" + gender;
	}
	
	public boolean equals(PersonOverride p1) {
		if(this.name 

.equals(p1.name 

)&&this.age==p1.age&&this.gender==p1.gender) return true;
		else return false;
	}
	
}
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in 

);
		int n1 = sc.nextInt();
		int n2 = sc.nextInt();
		int k=0;
		ArrayList<PersonOverride> pe1 = new ArrayList<PersonOverride>();
		ArrayList<PersonOverride> pe2 = new ArrayList<PersonOverride>();
		for (int i = 0; i < n1; i++) {
			pe1.add(new PersonOverride());
		}
		//System.out.println(666);
		for (int i = 0,j; i < n2; i++) {
			boolean b;
			String str = new String(sc.next());
			//System.out.println(str);
			j = sc.nextInt();
			//System.out.println(j);
			//sc.nextLine();
			b=sc.nextBoolean();
			//System.out.println(b);
			/*if(pe2.contains((new PersonOverride(str,j,b)))==false) {
				System.out.println(pe2.contains((new PersonOverride(str,j,b))));
				pe2.add(new PersonOverride(str,j,b));
			}*/
			PersonOverride po = new PersonOverride(str,j,b);
			//System.out.println(pe2.size());
			/*for (k = 0; k < pe2.size(); k++) {
				System.out.println(pe2.size());
				if(po.equals(pe2.get(k))) break;
				System.out.println(666);
			}*/
			//if(!po.equals(pe2.get(pe2.size()-1))&&k==pe2.size()) pe2.add(po);
			//sc.nextLine();
			//System.out.println(555);
			for (PersonOverride po1 : pe2) {
				if(!po.equals(po1)) break;
				k++;
			}
			if(k==pe2.size()) pe2.add(po);
		}
		for (int i = 0; i < n1; i++) {
			System.out.println(pe1.get(i).toString());
		}
		for (int i = 0; i < pe2.size(); i++) {
			System.out.println(pe2.get(i).toString());
		}
		System.out.println(pe2.size());
		System.out.println(Arrays.toString(PersonOverride.class.getConstructors()));
		//System.out.println("[public PersonOverride(), public PersonOverride(java.lang.String,int,boolean)]");
	}

}

